#include "Vec3.hpp"
#include <boost/signals.hpp>

class ViewPoint;
class Controller;
// handles many editing functions, as well as displaying the red 'control point'
class ControlPoint : public boost::signals::trackable
{
public:
   ControlPoint(ViewPoint*  aViewPoint,
                Controller* aController);
   enum Mode
   {
      cPASSIVE,
      cROTATE,
      cSCALE,
      cTRANSLATE
   };

   void Draw();
   void DrawWindow();
   int handle(int event);
   int HandleRotation(int event);
   int HandleScale(int event);
   void HandleSelectionChange();
   void DrawArrow(Vec3 aDirection);

   bool ArrowIntersect(Vec3 aRayOrigin,
                       Vec3 aRay,
                       Vec3 aDirection);

   void GetArrowVerts(Vec3 aDirection, std::vector<Vec3>& aVerts);
   void GetArrowVerts(Vec3 aX, Vec3 aY, std::vector<Vec3>& aVerts);
   void SetMode(Mode aMode) { SetModeP(mCurrentMode == aMode ? cPASSIVE : aMode); }
private:
   void SetModeP(Mode aMode);
public:

   Mode        mCurrentMode;
   Controller* mController;
   ViewPoint*  mViewPoint;
   Vec3        mPoint;

   Vec3        mSavedPoint;
   int         mAxisDown; 
   Vec2        mScreenPoint;
   bool        mTranslateMode;
   bool        mFreeTranslateMode;
   int         mRotationMode;
   int         mScaleMode;
   bool        mIsVisible;
};
